// 方式一
// 暴力解法，时间复杂度高
function findMedianSortedArrays(nums1, nums2) {
  const mergeArr = [...nums1, ...nums2].sort((a, b) => a - b);
  const len = mergeArr.length;
  const midLeft = Math.floor(len / 2);
  const midRight = Math.ceil(len / 2);
  if (midLeft === midRight) {
    return (mergeArr[midLeft - 1] + mergeArr[midRight]) / 2;
  }
  return mergeArr[midLeft];
}

const ret = findMedianSortedArrays([1, 3], [2, 4]);

console.log(ret);
